home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / PROGRAMM / CC_C / 0696A.ZIP / TIMEDATA.C < prev    next >
Text File  |  1987-05-25  |  704b  |  26 lines

  1. #include <stdio.h>
  2. #include <time.h>
  3.  
  4. main()
  5. {
  6.     long now;
  7.     struct tm *tbuf;
  8. /* get TZ data into global variables */
  9. tzset();
  10. /* display the global time values */
  11. printf("daylight savings time flag = %d\n", daylight);
  12. printf("difference (in seconds) from GMT = %ld\n", timezone);
  13. printf("standard time zone string is %s\n", tzname[0]);
  14. printf("daylight time zone string is %s\n", tzname[1]);
  15.  
  16. /**
  17. * display the current date and time values for local and universal time
  18. **/
  19. now = time(NULL);
  20. printf("\nctime():\t%s\n", ctime(&now));
  21. tbuf = localtime(&now);
  22. printf("local time:\t%s\n", asctime(tbuf));
  23. tbuf = gmtime(&now);
  24. printf("universal time:\t%s\n", asctime(tbuf));
  25. exit(0);
  26. }